<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Список записей</title>
    <!-- Подключение стилей (замените на свои стили или Bootstrap) -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f8f9fa;
            margin: 0;
            padding: 0;
        }

        .container {
            max-width: 800px;
            margin: 20px auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        p {
            margin: 0;
            padding: 10px;
            border-bottom: 1px solid #ccc;
        }

        a {
            text-decoration: none;
            color: #007bff;
            font-weight: bold;
        }

        a:hover {
            color: #0056b3;
        }

        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }

        .pagination a {
            color: #007bff;
            padding: 8px 16px;
            text-decoration: none;
            border: 1px solid #007bff;
            border-radius: 4px;
            margin: 0 4px;
        }

        .pagination .current {
            background-color: #007bff;
            color: #fff;
            border: 1px solid #007bff;
            border-radius: 4px;
            padding: 8px 16px;
            margin: 0 4px;
        }

        .search-button {
            display: block;
            margin: 20px auto;
            padding: 10px 20px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            text-decoration: none;
            font-weight: bold;
        }

        .search-button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>

{% block content %}

<div class="col-lg-6 col-md-8">
    <ul>
        {% for obj in object_list %}
            <li><a href="{% url 'list_detail' obj.pk %}">{{ obj.name }} {{ obj.firstname }} {{ obj.midname }}</a></li>
        {% endfor %}
    </ul>

    <div class="button-group">
       <p> <button class="btn btn-primary" onclick="history.back();"> НАЗАД </button>
       <button class="btn btn-primary" onclick="window.location.href='/'"> ГЛАВНАЯ </button> </p>
    </div>
</div>

<div class="pagination">
    <span class="step-links">
        {% if page_obj.has_previous %}
{#            <a href="?page=1">&laquo; first</a>#}
{#            <a href="?page={{ search.previous_page_number }}">previous</a>#}
{#            <a href="?{{ request.GET.urlencode }}&page=1">&laquo; first</a>#}
{#            <a href="?{{ request.GET.urlencode }}&page={{ search.previous_page_number }}">previous</a>#}
            <a href="?{% for key, value in request.GET.items %}{% if key != 'page' %}{{ key }}={{ value }}{% if not forloop.last %}&{% endif %}{% endif %}{% endfor %}&page=1">&laquo; first</a>
            <a href="?{% for key, value in request.GET.items %}{% if key != 'page' %}{{ key }}={{ value }}{% if not forloop.last %}&{% endif %}{% endif %}{% endfor %}&page={{ page_obj.previous_page_number }}">previous</a>
        {% endif %}

        <span class="current">
            Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
        </span>

        {% if page_obj.has_next %}
{#            <a href="?page={{ search.next_page_number }}">next</a>#}
{#            <a href="?page={{ search.paginator.num_pages }}">last &raquo;</a>#}
{#            <a href="?{{ request.GET.urlencode }}&page={{ search.next_page_number }}">next</a>#}
{#            <a href="?{{ request.GET.urlencode }}&page={{ search.paginator.num_pages }}">last &raquo;</a>#}
            <a href="?{% for key, value in request.GET.items %}{% if key != 'page' %}{{ key }}={{ value }}{% if not forloop.last %}&{% endif %}{% endif %}{% endfor %}&page={{ page_obj.next_page_number }}">next</a>
            <a href="?{% for key, value in request.GET.items %}{% if key != 'page' %}{{ key }}={{ value }}{% if not forloop.last %}&{% endif %}{% endif %}{% endfor %}&page={{ page_obj.paginator.num_pages }}">last &raquo;</a>
        {% endif %}
    </span>
</div>
{% endblock content %}

</body>
</html>
